<include file="Public/loginheader"/>
<div class="loginbox">
	<div class="wrapper">
		<div class="right-login fr">
			<div class="login-title">
				<h3>用户注册</h3>
			</div>
			<div class="login-content">
				<form id="register_form" method="post" action="" novalidate="novalidate">
					<dl>
						<dt>用户名</dt>
						<dd style="min-height:54px;">
							<input autocomplete="off" type="text" id="member_name" name="member_name" class="text tip error" title="3-20位字符，可由中文、英文、数字及“_”、“-”组成">
							<label style="display: none;"></label>
							<label for="member_name" generated="true" class="error"></label>
                        </dd>
					</dl>
					<dl>
						<dt>邮箱地址</dt>
						<dd style="min-height:54px;">
							<input type="text" id="email" name="email" class="text tip error" title="请输入您的邮箱地址">
							<label style="display: none;"></label>
							<label for="email" generated="true" class="error"></label></dd>
					</dl>                    
			
					<dl>
						<dt>设置密码</dt>
						<dd style="min-height:54px;">
							<input type="password" id="pwd" name="pwd" class="text tip error" title="6-16位字符，可由英文、数字及标点符号组成" autocomplete="off">
							<label style="display: none;"></label>
							<label for="pwd" generated="true" class="error"></label>
						</dd>
					</dl>
					<dl>
						<dt>确认密码</dt>
						<dd style="min-height:54px;">
							<input type="password" id="pwder" name="pwder" class="text tip error" title="请再次输入您的密码" autocomplete="off">
							<label style="display: none;"></label>
							<label for="pwder" generated="true" class="error"></label></dd>
					</dl>

                    <dl>
                        <dt>邀请码</dt>
                        <dd style="min-height:54px;">
                            <input autocomplete="off" type="text" name="invite_code" class="text tip error" title="必须要优邀请码才能注册" id="invite_code" maxlength="8" size="10" style="width: 50px">
                            <label style="display: none;"></label>
                            <label for="invite_code" generated="true" class="error"></label>
                        </dd>
                    </dl>

					<dl>
						<dt>验证码</dt>
						<dd style="min-height:54px;">
							<input type="text" name="captcha" class="text fl" id="captcha" maxlength="4" size="10" style="width: 50px">
							<img src="{:U('get_verify')}" id="codeimg" class="fl" style="margin-left: 15px;" onclick="changecode()"> 
                            <a href="javascript:changecode();" style="margin-left: 15px;">看不清，换一张</a>
							<label></label>
						</dd>
					</dl>
					<dl style="margin: 10px 0;">
						<dt>&nbsp;</dt>
						<input type="submit" name="Submit" value="立即注册" class="submit fl" title="立即注册">
						<dd class="fl" style="width: 45%;margin: 5px 10px;">
                        <input name="agree" type="checkbox" class="fl" id="clause" value="1" checked="checked" style="margin: 8px;">
                        <span for="clause" class="fl ml5">阅读并同意<a href="" target="_blank" class="agreement" title="阅读并同意">服务协议</a></span>
                        <label></label>
                        </dd>
					</dl>
				</form>
				<dl style="margin: 10px 0;">
					<dt>&nbsp;</dt>
					<dd>已有账号？立即<a title="" href="{:U('index')}" class="register">登录</a></dd>
				</dl>
				<div class="clear"></div>
			</div>
			<div class="login-bottom"></div>
		</div>




		<strong>分享知识，发表您的观点！</strong>
<div class="clear"></div>
	</div>
</div>


<div class="ico-box">
	<div class="wrapper">
		<ul>
			<li><img src="__IMG__/1.png" alt=""><p>分享知识</p></li>
			<li><img src="__IMG__/2.png" alt=""><p>多元观点</p></li>
			<li><img src="__IMG__/3.png" alt=""><p>发表见解</p></li>
			<li><img src="__IMG__/4.png" alt=""><p>自由评论</p></li>
		</ul>
		<div class="clear"></div>
	</div>
</div>

<div class="foot">
	<div class="wrapper">
      <p> Copyright © 2004-2015 icp号:123456789  </p>    
    </div>   
</div>


<div class="weixin">	
	<p>扫描二维码</p>
	<p>关注辩论网微信</p>
	<img style="margin-top:20px;" src="__IMG__/wx.png" width="120" height="120" alt="">	
</div>	


<!-- 注册判断 -->
<script>
//注册表单验证
$(function(){
		jQuery.validator.addMethod("isMobile", function(value, element) {
		var length = value.length;
		var mobile = /^1[3|4|5|7|8][0-9]\d{4,8}$/;
		return this.optional(element) || (length == 11 && mobile.test(value));
		}, "Mobile phone format error");
	
		jQuery.validator.addMethod("lettersonly", function(value, element) {
			return this.optional(element) || /^[^:%,'\*\"\s\<\>\&]+$/i.test(value);
		}, "Letters only please"); 
		jQuery.validator.addMethod("lettersmin", function(value, element) {
			return this.optional(element) || ($.trim(value.replace(/[^\u0000-\u00ff]/g,"aa")).length>=3);
		}, "Letters min please"); 
		jQuery.validator.addMethod("lettersmax", function(value, element) {
			return this.optional(element) || ($.trim(value.replace(/[^\u0000-\u00ff]/g,"aa")).length<=15);
		}, "Letters max please");
    $("#register_form").validate({
        errorPlacement: function(error, element){
            var error_td = element.parent('dd');
            error_td.find('label').hide();
            error_td.append(error);
        },
        submitHandler:function(form){
            ajaxpost('register_form', '', '', 'onerror') 
        },
		onkeyup: false,
        rules : {
            member_name : {
                required : true,
                lettersmin : true,
                lettersmax : true,
                lettersonly : true,
                remote   : {
                    url : "{:U('check_member')}",
                    type:'get',
                    data:{
                        member_name : function(){
                            return $('#member_name').val();
                        }
                    }
                }
            },
            email : {
                required : true,
                email    : true,
                remote   : {
                    url : "{:U('check_email')}",
                    type: 'get',
                    data:{
                        email : function(){
                            return $('#email').val();
                        }
                    }
                }
            },				
/*            mobile : {
                required : true,
				isMobile : true, 
                remote   : {
                    url : "{:U('check_phone')}",
                    type:'get',
                    data:{
                        mobile : function(){
                            return $('#mobile').val();
                        }
                    }
                }				 
            },
		    gc_id_1 : {
                required : true
            },	*/					
            pwd : {
                required : true,
                minlength: 6,
				maxlength: 20
            },
            pwder : {
                required : true,
                equalTo  : '#pwd'
            },
            invite_code : {
                required : true,
                remote   : {
                    url : "{:U('check_invite_code')}",
                    type:'get',
                    data:{
                        invite_code : function(){
                            return $('#invite_code').val();
                        }
                    },
                    complete: function(data) {
                        if(data.responseText === 'false'){
                            $('label[for="invite_code"]').text("邀请码错误");
                        }
                    }
                }
            },
		    captcha : {
                required : true,
                remote   : {
                    url : "{:U('check_verify')}",
                    type:'get',
                    data:{
                        captcha : function(){
                            return $('#captcha').val();
                        }
                    },
                    complete: function(data) {
                        if(data.responseText == 'false'){
							document.getElementById('codeimg').src="{:U('get_verify')}"+"?"+Math.random();  
                        }
                    }					
                }					
            },
			agree : {
                required : true
            }
        },
        messages : {
            member_name : {
                required : '用户名不能为空',
                lettersmin : '用户名必须在3-15个字符之间',
                lettersmax : '用户名必须在3-15个字符之间',
				lettersonly: '用户名不能包含敏感字符',
				remote	 : '该用户名已经存在'
            },
            email : {
                required : '邮箱不能为空',
                email    : '邮箱格式错误',
                remote   : '该邮箱已存在'
            },			
/*            mobile : {
                required : '手机号码不能为空',
				isMobile : '手机号码格式不正确',  
				remote : '该手机号码已经存在'
            },	
		    gc_id_1 : {
                required : '请选择所属学校'
            },	*/						
            pwd  : {
                required : '密码不能为空',
                minlength: '密码长度应在6-20个字符之间',
				maxlength: '密码长度应在6-20个字符之间'
            },
            pwder : {
                required : '请再次输入您的密码',
                equalTo  : '两次输入的密码不一致'
            },
            invite_code : {
                required : '请输入邀请码',
                remote   : '邀请码不正确'
            },
			captcha : {
                required : '请输入验证码',
                remote   : '验证码不正确'			
            },
			agree : {
                required : '请阅读并同意该协议'
            }
        }
    });
});
function changecode(){
	document.getElementById('codeimg').src="{:U('get_verify')}"+"?"+Math.random();
}
</script>
</body>
</html>